#pragma once
#include <thread>
#include <string>
#include "Famicom.h"
#include "AsciiView.h"

#define FC_WITDH 256
#define FC_HEIGHT 240

class FcThread : public IFcEvent
{
public:
	enum
	{
		EVENT_RELOADROM = 0x1,
		EVENT_SAVE_STATE = 0x2,
		EVENT_RESTORE_STATE = 0x4,
		EVENT_PAUSE = 0x8,
	};
	FcThread();
	~FcThread();
	void Start();
	void Stop();
	void run();

	void SyncLoadRom(std::string strFilename);

	//IFcEvent
	virtual bool OnSaveBundleOpen(bool issave)override;
	virtual bool OnSaveBundleClose()override;
	virtual void OnSaveBundleWrite(char* buf, int size)override;
	virtual void OnSaveBundleRead(char* buf, int size)override;
	virtual void OnAudioWrite(short* buf, int size)override;

private:
	std::thread m_thread;
	bool m_bRunning;
	Famicom* m_famicom;
	famicom_rom_t* m_rom;
	AsciiView m_view;
	std::string m_strFilename;
	int m_flag;
};

